

local Scope = import("../window/Script/Scope.lua");

local scope = Scope();

scope.__index_global_callback__ = function(scope, key)
    print("__index_callback__", scope, key);
end


scope.__newindex_global_callback__ = function(scope, key, val)
    print("__newindex_callback__", scope, key, val);
end

scope.key = "value";
scope.obj = {};

local obj = scope.obj;
obj.key = "test";

print("----------------------------------------------------")
commonlib.dostring("print(obj.key)", scope);
print("----------------------------------------------------")
-- local __data__ = {};
-- setmetatable(Scope, {
--     __newindex = function(obj, key, val) 
--         print("__newindex", obj, key, val);
--         __data__[key] = val;
--     end,
--     __index = function(obj, key)
--         print("__index", obj, key);
--         return __data__[key];
--     end,
--     __len = function(obj)
--         print("__len-------------------------------", obj);
--         return #__data__; 
--     end,
--     __ipairs = function (obj)
--         print("------------------------------__ipairs", obj);
--         return ipairs(__data__);
--     end,
--     __pairs = function(obj)
--         print("__pairs", obj);
--         return pairs(__data__);
--     end
-- });


-- Scope["key"] = "value";
-- Scope[1] = 3;
-- Scope[2] = 4;


-- print(Scope.key);

-- print(#Scope)
-- print("------------------------------------------------------", rawget(Scope, 1))
-- for _, val in ipairs(Scope) do

--     print(val)
-- end

-- for key, val in pairs(Scope) do
--     print(key, val);
-- end
